<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>控制面板 - 测盟汇系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        :root {
            --primary-color: #2c5545;
            --primary-light: #3a7d62;
            --primary-hover: #1e4636;
            --accent-color: #8ba888;
            --error-color: #d64541;
            --success-color: #3a7d62;
            --text-color: #333;
            --text-light: #555;
            --border-color: #d1d9d6;
            --bg-light: #f5f7f6;
            --bg-page: #e8ecea;
            --white: #fff;
            --shadow: 0 4px 24px rgba(44, 85, 69, 0.1);
            --radius: 12px;
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: var(--text-color);
            line-height: 1.6;
            background-color: var(--bg-page);
            display: flex;
            min-height: 100vh;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 250px;
            background: var(--primary-color);
            color: var(--white);
            padding: 1.5rem 0;
            height: 100vh;
            position: fixed;
            transition: var(--transition);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 1.5rem 1.5rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .sidebar-header h3 {
            display: flex;
            align-items: center;
            font-weight: 600;
        }

        .sidebar-header h3 i {
            margin-right: 0.5rem;
            font-size: 1.2rem;
        }

        .sidebar-menu {
            padding: 1rem 0;
        }

        .menu-title {
            padding: 0.5rem 1.5rem;
            font-size: 0.8rem;
            text-transform: uppercase;
            color: rgba(255, 255, 255, 0.5);
            letter-spacing: 1px;
        }

        .menu-item {
            padding: 0.75rem 1.5rem;
            display: flex;
            align-items: center;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            transition: var(--transition);
        }

        .menu-item i {
            margin-right: 0.8rem;
            width: 20px;
            text-align: center;
        }

        .menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: var(--white);
        }

        .menu-item.active {
            background: var(--primary-hover);
            color: var(--white);
            border-left: 3px solid var(--accent-color);
        }

        /* 主内容区域 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 2rem;
            transition: var(--transition);
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--border-color);
        }

        .header h1 {
            color: var(--primary-color);
            font-size: 1.8rem;
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .user-profile img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 0.8rem;
            object-fit: cover;
        }

        .user-info {
            display: flex;
            flex-direction: column;
        }

        .user-name {
            font-weight: 500;
        }

        .user-role {
            font-size: 0.8rem;
            color: var(--text-light);
        }

        /* 登出按钮样式 */
        .logout-btn {
            margin-left: 1.5rem;
            padding: 0.5rem 1rem;
            background: var(--white);
            color: var(--error-color);
            border: 1px solid var(--error-color);
            border-radius: var(--radius);
            font-size: 0.9rem;
            text-decoration: none;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }

        .logout-btn:hover {
            background: var(--error-color);
            color: var(--white);
        }

        .logout-btn i {
            margin-right: 0.3rem;
        }

        /* 功能卡片 */
        .dashboard-cards {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .card {
            background: var(--white);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 1.5rem;
            transition: var(--transition);
            cursor: pointer;
            border: 1px solid var(--border-color);
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 30px rgba(44, 85, 69, 0.15);
        }

        .card-icon {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1rem;
            font-size: 1.2rem;
            color: var(--white);
        }

        .card-icon.course {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
        }

        .card-icon.activity {
            background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
        }

        .card-icon.meeting {
            background: linear-gradient(135deg, #f46b45 0%, #eea849 100%);
        }

        .card-icon.profile {
            background: linear-gradient(135deg, #8e2de2 0%, #4a00e0 100%);
        }

        .card-title {
            font-size: 1.2rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            color: var(--primary-color);
        }

        .card-desc {
            color: var(--text-light);
            font-size: 0.9rem;
            margin-bottom: 1rem;
        }

        .card-link {
            display: flex;
            align-items: center;
            color: var(--primary-light);
            font-size: 0.9rem;
            text-decoration: none;
            transition: var(--transition);
        }

        .card-link i {
            margin-left: 0.3rem;
            transition: var(--transition);
        }

        .card-link:hover {
            color: var(--primary-color);
        }

        .card-link:hover i {
            transform: translateX(3px);
        }

        /* 最近活动 */
        .recent-activity {
            background: var(--white);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 1.5rem;
            margin-top: 2rem;
        }

        .section-title {
            font-size: 1.3rem;
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            display: flex;
            align-items: center;
        }

        .section-title i {
            margin-right: 0.5rem;
        }

        .activity-list {
            list-style: none;
        }

        .activity-item {
            padding: 0.8rem 0;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
        }

        .activity-item:last-child {
            border-bottom: none;
        }

        .activity-icon {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--bg-light);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
            color: var(--primary-color);
        }

        .activity-content {
            flex: 1;
        }

        .activity-title {
            font-weight: 500;
            margin-bottom: 0.2rem;
        }

        .activity-time {
            font-size: 0.8rem;
            color: var(--text-light);
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3 span,
            .menu-title,
            .menu-item span {
                display: none;
            }

            .menu-item {
                justify-content: center;
                padding: 0.75rem 0;
            }

            .menu-item i {
                margin-right: 0;
                font-size: 1.2rem;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .dashboard-cards {
                grid-template-columns: 1fr;
            }

            .main-content {
                padding: 1.5rem;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
            }

            .user-profile {
                margin-top: 1rem;
                width: 100%;
                justify-content: space-between;
            }
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
        }

        .modal-content {
            background-color: var(--white);
            margin: 15% auto;
            padding: 2rem;
            border-radius: var(--radius);
            width: 400px;
            max-width: 90%;
            box-shadow: var(--shadow);
            position: relative;
        }

        .close-btn {
            position: absolute;
            right: 1rem;
            top: 1rem;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--text-light);
        }

        .close-btn:hover {
            color: var(--text-color);
        }

        .modal h2 {
            margin-bottom: 1.5rem;
            color: var(--primary-color);
        }

        .modal .form-group {
            margin-bottom: 1rem;
        }

        .modal label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--primary-color);
        }

        .modal input {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            font-size: 1rem;
        }

        .modal button {
            width: 100%;
            padding: 0.8rem;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1rem;
            transition: var(--transition);
        }

        .modal button:hover {
            background: var(--primary-hover);
        }

        .error-message {
            color: var(--error-color);
            margin-top: 1rem;
            text-align: center;
            font-size: 0.9rem;
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 -->
<div class="sidebar">
    <div class="sidebar-header">
        <h3><i class="fas fa-store"></i> <span>测盟汇系统</span></h3>
    </div>

    <div class="sidebar-menu">
        <div class="menu-title">核心功能</div>
        <a href="/index" class="menu-item active">
            <i class="fas fa-tachometer-alt"></i>
            <span>控制面板</span>
        </a>

        <div class="menu-title">功能模块</div>
        <a href="#" class="menu-item">
            <i class="fas fa-book-open"></i>
            <span>课程</span>
        </a>
        <a href="/dynamic_list" class="menu-item">
            <i class="fas fa-bullhorn"></i>
            <span>动态</span>
        </a>
        <a href="#" class="menu-item">
            <i class="fas fa-video"></i>
            <span>会议</span>
        </a>

        <div class="menu-title">系统设置</div>
        <a href="/user/profile" class="menu-item">
            <i class="fas fa-user-cog"></i>
            <span>个人资料</span>
        </a>
        <a href="#" class="menu-item" id="enterpriseProfileBtn">
            <i class="fas fa-building"></i>
            <span>企业资料修改</span>
        </a>
    </div>
</div>

<!-- 主内容区域 -->
<div class="main-content">
    <div class="header">
        <h1>控制面板</h1>
        <div class="user-profile">
            <img th:src="@{/images/default-avatar.jpg}" alt="用户头像">
            <div class="user-info">
                <span class="user-name" th:text="${session.user.nickname ?: session.user.username}">用户名</span>
                <span class="user-role" th:text="${session.user.isSuperAdmin ? '超级管理员' : '普通用户'}">用户角色</span>
            </div>
            <a href="/user/logout" class="logout-btn">
                <i class="fas fa-sign-out-alt"></i> 登出
            </a>
        </div>
    </div>

    <!-- 企业验证弹窗 -->
    <div id="enterpriseAuthModal" class="modal">
        <div class="modal-content">
            <span class="close-btn">&times;</span>
            <h2>企业身份验证</h2>
            <form id="enterpriseAuthForm">
                <div class="form-group">
                    <label for="enterpriseAccount">企业账号</label>
                    <input type="text" id="enterpriseAccount" required>
                </div>
                <div class="form-group">
                    <label for="enterprisePassword">企业密码</label>
                    <input type="password" id="enterprisePassword" required>
                </div>
                <button type="submit">验证</button>
                <div id="authError" class="error-message" style="display: none;"></div>
            </form>
        </div>
    </div>

    <!-- 功能卡片 -->
    <div class="dashboard-cards">
        <div class="card" onclick="window.location.href='#'">
            <div class="card-icon course">
                <i class="fas fa-book-open"></i>
            </div>
            <h3 class="card-title">课程管理</h3>
            <p class="card-desc">查看和管理您的课程，参与学习计划</p>
            <a href="#" class="card-link">进入课程 <i class="fas fa-arrow-right"></i></a>
        </div>

        <div class="card" onclick="window.location.href='/dynamic_list'">
            <div class="card-icon activity">
                <i class="fas fa-bullhorn"></i>
            </div>
            <h3 class="card-title">动态消息</h3>
            <p class="card-desc">查看最新动态和系统通知</p>
            <a href="/dynamic_list" class="card-link">查看动态 <i class="fas fa-arrow-right"></i></a>
        </div>

        <div class="card" onclick="window.location.href='#'">
            <div class="card-icon meeting">
                <i class="fas fa-video"></i>
            </div>
            <h3 class="card-title">会议管理</h3>
            <p class="card-desc">安排和参加在线会议</p>
            <a href="#" class="card-link">管理会议 <i class="fas fa-arrow-right"></i></a>
        </div>

        <div class="card" onclick="window.location.href='/user/profile'">
            <div class="card-icon profile">
                <i class="fas fa-user"></i>
            </div>
            <h3 class="card-title">个人中心</h3>
            <p class="card-desc">管理您的个人资料和设置</p>
            <a href="/user/profile" class="card-link">个人设置 <i class="fas fa-arrow-right"></i></a>
        </div>
    </div>

    <!-- 最近活动 -->
    <div class="recent-activity">
        <h2 class="section-title"><i class="fas fa-clock"></i> 最近活动</h2>
        <ul class="activity-list">
            <li class="activity-item">
                <div class="activity-icon">
                    <i class="fas fa-book"></i>
                </div>
                <div class="activity-content">
                    <div class="activity-title">您已报名参加"Spring Boot进阶课程"</div>
                    <div class="activity-time">2025-06-28 14:30</div>
                </div>
            </li>
            <li class="activity-item">
                <div class="activity-icon">
                    <i class="fas fa-users"></i>
                </div>
                <div class="activity-content">
                    <div class="activity-title">您被邀请参加"项目规划会议"</div>
                    <div class="activity-time">2025-06-27 10:15</div>
                </div>
            </li>
            <li class="activity-item">
                <div class="activity-icon">
                    <i class="fas fa-bell"></i>
                </div>
                <div class="activity-content">
                    <div class="activity-title">系统更新通知：版本1.2.0已发布</div>
                    <div class="activity-time">2025-06-26 09:00</div>
                </div>
            </li>
            <li class="activity-item">
                <div class="activity-icon">
                    <i class="fas fa-check-circle"></i>
                </div>
                <div class="activity-content">
                    <div class="activity-title">您已完成"Java基础测试"</div>
                    <div class="activity-time">2025-06-25 16:45</div>
                </div>
            </li>
        </ul>
    </div>
</div>

<script>
    // 设置当前激活菜单项
    document.addEventListener('DOMContentLoaded', function() {
        const menuItems = document.querySelectorAll('.menu-item');
        const currentPath = window.location.pathname;

        menuItems.forEach(item => {
            if (item.getAttribute('href') === currentPath ||
                (currentPath === '/index' && item.getAttribute('href') === '/index')) {
                item.classList.add('active');
            } else {
                item.classList.remove('active');
            }

            item.addEventListener('click', function(e) {
                if (this.getAttribute('href') === '#') {
                    e.preventDefault();
                }
            });
        });

        // 卡片点击效果
        const cards = document.querySelectorAll('.card');
        cards.forEach(card => {
            card.addEventListener('click', function() {
                const link = this.querySelector('a');
                if (link) {
                    window.location.href = link.getAttribute('href');
                }
            });
        });

        // 企业验证弹窗逻辑
        const modal = document.getElementById('enterpriseAuthModal');
        const btn = document.getElementById('enterpriseProfileBtn');
        const closeBtn = document.querySelector('.close-btn');
        const authForm = document.getElementById('enterpriseAuthForm');
        const errorMsg = document.getElementById('authError');

        // 打开弹窗
        btn.addEventListener('click', function(e) {
            e.preventDefault();
            modal.style.display = 'block';
        });

        // 关闭弹窗
        closeBtn.addEventListener('click', function() {
            modal.style.display = 'none';
            errorMsg.style.display = 'none';
        });

        // 点击外部关闭
        window.addEventListener('click', function(e) {
            if (e.target === modal) {
                modal.style.display = 'none';
                errorMsg.style.display = 'none';
            }
        });

        // 表单提交
        authForm.addEventListener('submit', function(e) {
            e.preventDefault();

            const account = document.getElementById('enterpriseAccount').value;
            const password = document.getElementById('enterprisePassword').value;

            // 发送验证请求
            fetch('/enterprise/verify', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    account: account,
                    password: password
                })
            })
                .then(response => {
                    if (!response.ok) {
                        throw new Error('验证失败');
                    }
                    return response.json();
                })
                .then(data => {
                    if (data.success) {
                        // 验证成功，跳转到企业资料页面
                        window.location.href = '/enterprise/profile';
                    } else {
                        // 验证失败
                        errorMsg.textContent = data.message || '企业账号或密码错误';
                        errorMsg.style.display = 'block';
                    }
                })
                .catch(error => {
                    errorMsg.textContent = '验证过程中发生错误: ' + error.message;
                    errorMsg.style.display = 'block';
                });
        });
    });
</script>
</body>
</html>